一些在 react native 中实用的方法
在 Text 中实现换行
要实现在 Text 组件中进行换行,需要在文本中间加入 {'\n'} :
1 | <Text> |
测量控件的宽高
使用 view 的 onLayout 方法
1 | <Text onLayout={(e) => this._layout(e)}></Tex> |
使用标签的 measure 方法
1 | <Text ref='text'></Text> |
如果不使用
setTimeout会出现结果为 0 的情况